home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10111 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.0 KB  |  70 lines

  1. Path: mother.usf.edu!news
  2. From: yatesc@csee.usf.edu (Randy Yates)
  3. Newsgroups: comp.sources.wanted,comp.lang.c,comp.unix.programmer
  4. Subject: Re: Seek unix2dos.c OR help with tr - unix2dos.zip [0/3]
  5. Date: 15 Mar 1996 17:56:01 GMT
  6. Organization: University of South Florida
  7. Distribution: ibm
  8. Message-ID: <4icavh$oiv@mother.usf.edu>
  9. References: <4i0946$7io@nuke.csu.net> <4i1g2v$m12@watnews1.watson.ibm.com>
  10. NNTP-Posting-Host: ppp174.cfr.usf.edu
  11. Mime-Version: 1.0
  12. Content-Type: message/partial;
  13.      id="826923680@Randy Yates";
  14.      number=1; total=4
  15. X-Newsreader: WinVN 0.93.14
  16.  
  17. Content-Type: multipart/mixed;
  18.      Boundary="*-*-*- Next Section -*-*-*"
  19.  
  20. --*-*-*- Next Section -*-*-*
  21.  
  22. In article <4i1g2v$m12@watnews1.watson.ibm.com>, kgold@watson.ibm.com 
  23. says...
  24. >
  25. > mclean@futon.SFSU.EDU (Emmett Mclean) writes:
  26. >|> 
  27. >|> Does anyone have the source to a program
  28. >|> converting a unix file into dos format?
  29. >|> That is, each decimal 10 char is replaced
  30. >|> with a series of a 10 and 13.
  31. >|> 
  32. >|>[snip]
  33. >|> 
  34. >|> I will be using it to download zipped binaries
  35. >|> files from a unix box.
  36. >|> 
  37. >|> Ah, writing the program is a bit trickier
  38. >|> than the little program below since the
  39. >|> program exits prematurely because getchar reads
  40. >|> EOF from its input - before getting to
  41. >|> the real EOF.
  42. >|> 
  43. >|> #include <stdio.h>
  44. >|> main(){
  45. >|> char c;
  46. >|> while(EOF!=(c=getchar())){
  47. >|>  if(10==c)putchar(13);
  48. >|>  putchar(c);
  49. >|>  }
  50. >|>  putchar(10);
  51. >|> }
  52. >|> 
  53. >
  54. >The tricky part is that getchar() returns an int, not a char.
  55. >It does that so EOF does not collide with a legal 8 bit char.
  56. >
  57. >BTW, if you're using an AIX machine, aix2dos and dos2aix are
  58. >included and do exactly what you want.
  59. >
  60. >-- 
  61. >Ken Goldman   kgold@watson.ibm.com   914-784-7396
  62.  
  63. -- 
  64. % Randy Yates                  % "...the answer lies within your soul
  65. % EE/Mathematics Student       %       'cause no one knows which side 
  66. % University of South Florida  %                   the coin will fall."
  67. % <yatesc@csee.usf.edu>        %  'Big Wheels', *Out of the Blue*, ELO   
  68. --*-*-*- Next Section -*-*-*
  69.  
  70.